package com.anysoft.controller;

import com.anysoft.model.Person;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/person")
public class PersonPracController {
    @RequestMapping("/input")
    public String input(Model model) {
        return "indexJson";
    }

    @RequestMapping("/testJson")
    @ResponseBody
    public Person testJson(@RequestBody Person user) {
        // 打印接收的JSON格式数据
        System.out.println("pname=" + user.getPname() + ",password=" + user.getPassword() + ",page" + user.getPage());
        // 返回JSON格式的响应
        return user;
    }
}
